#ifndef __GAF_TIMER_H__
#define __GAF_TIMER_H__

#include "GAF_Define.h"

namespace GAF
{
	//class RunBase
		class Timer;
}
typedef GAF::Timer			GAF_CTimer;

#include <memory>
#include "GAF_Run.h"

namespace GAF
{
	/// 定时器类
	class Timer : public RunBase
	{
	friend class Application;

	private:
		typedef STD_LIST<Timer*>	TimerList;

		static void			UpdateTimers();
		static void			UpdateExactTimers();
	private:
		static void			AddTimer(Timer* pTimer);
		static void			RemoveTimer(Timer* pTimer);

	private:
// 		static TimerList		ms_lstTimers;
// 		static TimerList		ms_lstExactTimers;
// 		static unsigned int		NameID;

	public:
		Timer();
// 		Timer(STD_STRING strName);
		virtual ~Timer();

	public:
		/// 精准计时
		void				Exact();

		/// 运行定时器
		bool				Start(TimeTicks ttInterval = 0);
		/// 停止定时器
		void				Stop();
	
		/// 获得定时器名称
		STD_STRING			GetName();

		/// 定时器是否正在运行
		bool				IsRun();

	public:
		/// 当定时器响应时
		virtual void			OnRunTimer();

	private:
		void				Update();

	private:
// 		STD_STRING			m_strName;
		TimeTicks			m_ttSave;
		bool				m_isRun;
	};
}
#endif
